#Init
foodX .word 0
foodY .word 1
snakeLen .word 3
stepX .word 4
stepY .word 5
direction .word 6
snakeArrayBase .word 7

i .word 100
Init:
	#init snake head
	mov r0,4
	mov r1,snakeArrayBase
	sw r0,(0)r1//设置蛇头初始X位置
	sw r0,(1)r1//设置蛇头初始Y位置
	//r0,r1使用完毕
	mov r0,1
	mov r1,snakeLen
	sw r0,(0)r1//设置蛇长度
	//r0,r1使用完毕

	
	//init step and direction
	mov r0, 1
	mov r1,stepX
	sw r0, (0)r1//设置X方向速度为1
	mov r0, 0
	mov r1,stepY
	sw r0, (0)r1//设置y方向速度为0

	mov r0,1//1是向右转
	mov r1,direction
	sw r0,0(r1)//设置方向

DrawSnake:
	load r
	load r0, snakeLen
	move r1, 0
	store r1, i

UpdateSnakeHead:
	lw r0 snakePos	#snakeX address
	load r1 r0				#load snakeX
	add r2,r1,stepX			#add snakeX with 1
	store r2,r0				#rewrite snake X
	add r0,r0,1				#snakeY address
	load r2,r0
	add r2,r2,stepY
	store r2,r0
UpdateSnakeBody:
	add r0,r0,1 			#next x
	load r2,r0
	store r1,r0
	mov r1,r2
	load r3,i
	add r3,r3,1
	store r3,i
	bne r3,0,Show
	jump UpdateSnakeBody

Show:
	


